package com.zzj.controller;


import com.zzj.bean.TabRole;
import com.zzj.service.TabRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * InnoDB free: 8192 kB 前端控制器
 * </p>
 *
 * @author 花
 * @since 2022-03-04
 */
@RestController
@RequestMapping("/role")
@CrossOrigin
@Api
public class TabRoleController {

    @Autowired
    private TabRoleService service;

    @GetMapping("findRole")
    @ApiOperation("根据用户的id查询他没有角色")
    public List<TabRole> findRoleByUserId(String userId){
        System.out.println("userId = " + userId);
        List<TabRole> all = service.list();
        System.out.println("all = " + all);
        List<TabRole> list = service.findRoleByUserId(userId);
        all.removeAll(list);
        System.out.println("all = " + all);
        return all;
    }

    @GetMapping("selectRole")
    @ApiOperation("根据用户的id查询他拥有角色")
    public List<TabRole> selectRoleByUserId(String userId){
        List<TabRole> list = service.findRoleByUserId(userId);
        return list;
    }

    @GetMapping("findAll")
    @ApiOperation("查询所有角色")
    public List<TabRole> findAll(){
/*        QueryWrapper<Role> qw = new QueryWrapper<>();
        qw.notIn("role_id",1);*/
        return service.list();
    }



}

